<?php
namespace App\Http\Controllers\Agency;

use App\Models\Sys_Menu;
use App\Models\Sys_Role;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use hg\apidoc\annotation as Apidoc;

/**
 * 路由菜单
 * @Apidoc\Group("base")
 */

class MenuController extends Controller
{
    /**
     * @Apidoc\Title ("菜单列表")
     * @Apidoc\Url("/agency/menuList")
     * @Apidoc\Method("GET")
     * @Apidoc\Header("Authorization", type="string",require=false, desc="Bearer + accessToken")
     * @Apidoc\Param("roleid",type="int",desc="角色id",mock="@roleid")
     * @Apidoc\Returned("is_menu",type="string",desc="is_menu")
     * @Apidoc\Returned("path",type="string",desc="path")
     * @Apidoc\Returned("component",type="string",desc="component")
     * @Apidoc\Returned("meta",type="object",desc="meta")
     * @Apidoc\Returned("children",type="array",desc="子菜单数组")
     *
     */
    public function menuList(Request $request)
    {
//        $roleid = $request->input('roleid');
//        $info = Sys_Role::find($roleid);
//        $list = Sys_Menu::whereIn('id',json_decode($info->menu_ids,true))
//                ->orderBy('order','asc')
//                ->get()
//                ->toArray();
        $list = Sys_Menu::orderBy('order','asc')
            ->get()
            ->toArray();
        $arr = $this->getChild($list);
        return $this->responseSuccess($arr);
    }
}
